package at.horario.model;

import javax.persistence.*;
import java.io.Serializable;

/**
 * Created by IntelliJ IDEA.
 * User: at
 * Date: 16/Set/2007
 * Time: 13:28:02
 * To change this template use File | Settings | File Templates.
 */
@Entity
public class Celula extends GenericObject<Long> implements Serializable {
    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "horarioId")
    private Horario horario;
    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "professorId")
    private Professor professor;
    private Integer turma;
    private Integer numeroHorario;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long celulaId;


    public Celula(Horario horario, Professor professor, Integer numeroHorario, Integer turma) {
        this.horario = horario;
        this.professor = professor;
        this.turma = turma;
        this.numeroHorario = numeroHorario;
    }

    public Celula() {
    }

    public Horario getHorario() {
        return horario;
    }

    public void setHorario(Horario horario) {
        this.horario = horario;
    }

    public Professor getProfessor() {
        return professor;
    }

    public void setProfessor(Professor professor) {
        this.professor = professor;
    }

    public Integer getTurma() {
        return turma;
    }

    public void setTurma(Integer turma) {
        this.turma = turma;
    }

    public Integer getNumeroHorario() {
        return numeroHorario;
    }

    public void setNumeroHorario(Integer numeroHorario) {
        this.numeroHorario = numeroHorario;
    }


    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Celula)) return false;

        Celula celula = (Celula) o;

        if (!horario.equals(celula.horario)) return false;
        if (!numeroHorario.equals(celula.numeroHorario)) return false;
        if (!professor.equals(celula.professor)) return false;
        return turma.equals(celula.turma);

    }

    public int hashCode() {
        int result;
        result = horario.hashCode();
        result = 31 * result + professor.hashCode();
        result = 31 * result + turma.hashCode();
        result = 31 * result + numeroHorario.hashCode();
        return result;
    }

    public Long getId() {
        return celulaId;
    }

}
